package com.xiaojian.pick.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xiaojian.pick.entity.CommodityComment;
import com.xiaojian.pick.page.AjaxResult;
import com.xiaojian.pick.service.CommodityCommentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author whycode
 * @title: CommodityCommentController
 * @projectName campus-secondary-market-app---sys
 * @description: TODO
 * @date 2022/3/2510:37
 */

@RestController
@RequestMapping("/commComment")
public class CommodityCommentController {
    @Resource
    private CommodityCommentService commodityCommentService;


    @PostMapping("/add")
    public AjaxResult add(@RequestBody CommodityComment commodityComment){
        boolean save = commodityCommentService.save(commodityComment);
        return new AjaxResult(true).setData(save);
    }


    @GetMapping("/list")
    public AjaxResult list(@RequestParam("cId") Integer cId,
                           @RequestParam("page") Integer page,
                           @RequestParam("limit") Integer limit){

        Page<CommodityComment> res = commodityCommentService.queryByPage(cId, page, limit);

        return new AjaxResult(true).setData(res);
    }

}
